<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>分类管理</title>
	<!-- Tell the browser to be responsive to screen width -->
	<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
	<!-- Bootstrap 3.3.6 -->
	<link rel="stylesheet" href="${siteurl}bootstrap/css/bootstrap.min.css">
	<!-- Font Awesome -->
	<link rel="stylesheet" href="${siteurl}plugins/FontAwesome/css/font-awesome.min.css">
	<!-- Ionicons -->
	<link rel="stylesheet" href="${siteurl}plugins/ionicons201/css/ionicons.min.css">
	<!-- Theme style -->
	<link rel="stylesheet" href="${siteurl}dist/css/AdminLTE.min.css">
	<!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
	<link rel="stylesheet" href="${siteurl}dist/css/skins/_all-skins.min.css">

	<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
	<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
	<!--[if lt IE 9]>
	<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
	<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
	<![endif]-->
	[#include "/admin/common/commons.html"]
</head>
<body class="hold-transition skin-blue sidebar-mini"   >
<!-- Site wrapper -->
<div class="wrapper">

	<header class="main-header">
		<!-- Header Navbar: style can be found in header.less -->
		[#include "/admin/common/nav.html"]
	</header>

	<!-- =============================================== -->

	<!-- Left side column. contains the sidebar -->
	<aside class="main-sidebar">
		<!-- sidebar: style can be found in sidebar.less -->
		<section class="sidebar">
			<!-- Sidebar user panel -->
			<!-- Sidebar user panel -->
			[@user_panel /]
			<!-- search form -->
			[@sidebar_form /]
			<!-- /.search form -->
			<!-- sidebar menu: : style can be found in sidebar.less -->
			<ul class="sidebar-menu" data-widget="tree">
				<li class="header">主面板</li>
				[@menustag id=1]
				[#list list as item]
				[@menu item "1,41,42"]
				[/@menu]
				[/#list]
				[/@menustag]
			</ul>
		</section>
		<!-- /.sidebar -->
	</aside>

	<!-- =============================================== -->

	<!-- Content Wrapper. Contains page content -->
	<div class="content-wrapper">
		<!-- Content Header (Page header) -->
		<!-- Main content -->
		<section class="content">

			<!-- Default box -->
			<div class="col-xs-12">
				<div class="box box-default box-solid">
					<div class="box-header with-border">
						<h3 class="box-title">更新分类</h3>
					</div>
					<!-- /.box-header -->
					<!-- form start -->
					<form class="form-horizontal" action="${siteurl}admin/area/model_update.htm" method="post">
						<input type="hidden" name="id" value="${model.id}">
						<input type="hidden" name="pageNumber" value="${pageNumber!'1'}">
						<input type="hidden" id="lng" name="lng" value="${(model.lng)!''}">
						<input type="hidden" id="lat" name="lat" value="${(model.lat)!''}">
						<div class="box-body">
							<div class="form-group">
								<label for="name" class="col-sm-2 control-label">分类名称</label>
								<div class="col-sm-10">
									<input class="form-control" id="name" maxlength="20" name="name" placeholder="分类名称" value="${model.name!''}"   type="text">
								</div>
							</div>
							<div class="form-group">
								<label for="code" class="col-sm-2 control-label">分类编码</label>
								<div class="col-sm-10">
									<input class="form-control" id="code" maxlength="50" name="code" placeholder="分类编码" value="${model.code!''}"   type="text">
								</div>
							</div>
							<div class="form-group">
								<label for="map" class="col-sm-2 control-label">地图</label>
								<div class="col-sm-10" >
									<div id="map" style="height: 300px;"></div>
								</div>
							</div>
						</div>
						<!-- /.box-body -->
						<div class="box-footer">
							<button type="submit" class="btn btn-primary pull-right">更新</button>
						</div>
						<!-- /.box-footer -->
					</form>
				</div>
			</div>
			<!-- /.box -->

		</section>
		<!-- /.content -->
	</div>
	<!-- /.content-wrapper -->

	[#include "/admin/common/footer.html"]

	<!-- Control Sidebar -->
	[#include "/admin/common/aside.html"]

	<!-- /.control-sidebar -->
	<!-- Add the sidebar's background. This div must be placed
         immediately after the control sidebar -->
	<div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->

<!-- jQuery 2.2.3 -->
<script src="${siteurl}plugins/jQuery/jquery-2.2.3.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="${siteurl}bootstrap/js/bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="${siteurl}plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="${siteurl}plugins/fastclick/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="${siteurl}dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="${siteurl}dist/js/demo.js"></script>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.8&key=26485075eb195524d2b367121951ff0c"></script>
<script type="text/javascript">

    var center = new AMap.LngLat(${(model.lng)!'108.9480471611023'},${(model.lat)!'34.33422273578077'});//标准写法
    var map = new AMap.Map('map', {
        center:center,
        zoom:11
    });
    var marker;

    //创建标记
    marker =  new AMap.Marker({
        icon: "https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png",
        position: center
    });
    marker.setMap(map);


    AMap.plugin(['AMap.ToolBar','AMap.DistrictSearch'],function(){//异步加载插件
        var toolbar = new AMap.ToolBar();
        map.addControl(toolbar);

        var district = new AMap.DistrictSearch({
            // 返回行政区边界坐标等具体信息
            extensions: 'all',
            // 设置查询行政区级别为 区
            level: 'city'
        })

        district.search("${model.name!''}", function(status, result) {
            // 获取朝阳区的边界信息
            var bounds = result.districtList[0].boundaries
            var polygons = []
            if (bounds) {
                for (var i = 0, l = bounds.length; i < l; i++) {
                    //生成行政区划polygon
                    var polygon = new AMap.Polygon({
                        map: map,
                        strokeWeight: 3,
                        path: bounds[i],
                        fillOpacity: 0.5,
                        fillColor: '#CCF3FF',
                        strokeColor: '#CC66CC'
                    })
                   polygons.push(polygon);
                    polygon.on('click', function(event) {
                        $("#lat").val(event.lnglat.getLat());
                        $("#lng").val(event.lnglat.getLng());
                        if (marker) {
                            marker.setMap(null);
                            marker = null;
                        }
                        marker = new AMap.Marker({
                            icon: "https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png",
                            position: event.lnglat
                        });
                        marker.setMap(map);
                    });
                }
                // 地图自适应
                map.setFitView()
            }
        })
    });

   function clicks(){
       map.on('click', function(event) {
           $("#lat").val(event.lnglat.getLat());
           $("#lng").val(event.lnglat.getLng());
           if (marker) {
               marker.setMap(null);
               marker = null;
           }
           marker = new AMap.Marker({
               icon: "https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png",
               position: event.lnglat
           });
           marker.setMap(map);

       });
   }
</script>
</body>
</html>
